package com.chu.service.impl;

import com.chu.entity.JobPublish;
import com.chu.mapper.JobPublishMapper;
import com.chu.service.JobPublishService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class JobPublishServiceImpl implements JobPublishService {

    @Autowired
    private JobPublishMapper mapper;

    //根据职位分类查询职位发布的信息
    @Override
    public PageInfo<JobPublish> findJobByRecruitType(String jobType,String recruitName,String registrationTime,String deadline, int page, int size) {

        PageHelper.startPage(page,size);
        Map map = new HashMap();
        map.put("jobType",jobType);
        map.put("recruitName",recruitName);
        map.put("registrationTime",registrationTime);
        map.put("deadline",deadline);
        List<JobPublish> list = mapper.findJobByRecruitType(map);
        PageInfo<JobPublish> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(JobPublish record) {
        return 0;
    }

    @Override
    public int insertSelective(JobPublish record) {
        record.setCreatedate(new Date());
        return mapper.insertSelective(record);
    }

    @Override
    public JobPublish selectByPrimaryKey(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(JobPublish record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(JobPublish record) {
        return 0;
    }
}
